﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Post.aspx.cs" Inherits="ZX.WebApp.forum.ViewPost"
    MasterPageFile="~/forum/forum.Master" %>

<asp:Content ContentPlaceHolderID="Top" ID="pageTop" runat="server">
<% string _BoardID = this.GetStringFromQueryString("boardID", ""); 
    ZX.BLL.Extend.BaseBussnies bll = new ZX.BLL.Extend.BaseBussnies();
    System.Data.DataTable dt = bll.GetDataBySqlComm(string.Format("Select BoardName From forumBoard where id='{0}'", _BoardID));
    %>
<a href="board.aspx?">中旭论坛</a>>>><a href="thread.aspx?boardID=<%=_BoardID %>"><% =dt.Rows[0].ItemArray[0] %></a> 

<button id="btnNewPost" style="float:right;margin-right:5px; margin-bottom:2px;" onclick="javascript:Post();">
        发新贴</button>
        <button id="Button1" style="float:right; margin-right:5px; margin-bottom:2px;" onclick="javascript:Reply();">
        回复</button>
</asp:Content>
<asp:Content ContentPlaceHolderID="head" ID="pageHead" runat="server">
<script language="javascript" type="text/javascript">
    function Post() {
        parent.PostForumPost("/Extend/AutoloadForm.aspx?entity=forumPost&boardID=<%=this.GetStringFromQueryString("boardID", "") %>",refreshPage,this);
    }
    function Reply() {
        parent.PostForumPost("/Extend/AutoloadForm.aspx?entity=forumPost&threadID=<% =this.GetStringFromQueryString("threadID", "") %>&boardID=<%=this.GetStringFromQueryString("boardID", "") %>",fn,this);
    }
    function ReplyPost(id)
    {
     var _content = "<div style=\"border:1px solid #DDD\"><div>";
     _content = _content+"<span>"+document.getElementById("INFO"+id).innerHTML+"</span><span>"+ document.getElementById("DT"+id).innerHTML+"</span></div>";
     _content = _content+  document.getElementById("N"+id).innerHTML+"</div>"  
     var content = decodeURIComponent(_content);
     //alert(content);
     parent.PostForumPost("/Extend/AutoloadForm.aspx?entity=forumPost&threadID=<% =this.GetStringFromQueryString("threadID", "") %>&boardID=<%=this.GetStringFromQueryString("boardID", "") %>&content="+content,fn,this);
    }
    function refreshPage()
    {
         this.location="/forum/Thread.aspx?boardID=<%=this.GetStringFromQueryString("boardID", "") %>&r="+Math.random();
         //alert("");
    }

    function fn()
    {
         this.location="/forum/ViewPost.aspx?boardID=<%=this.GetStringFromQueryString("boardID", "") %>&threadID=<% =this.GetStringFromQueryString("threadID", "") %>&r="+Math.random();
    }
</script>
</asp:Content>
<asp:Content ContentPlaceHolderID="Content" ID="pageContent" runat="server">
    <%
        ZX.BLL.Extend.BaseBussnies bll = new ZX.BLL.Extend.BaseBussnies();
        string _threadID = this.GetStringFromQueryString("threadID", "");
        string _PageIndex = this.GetStringFromQueryString("page", "0");
        string _strSql = "SELECT TOP 1000 * FROM  (  SELECT ROW_NUMBER() OVER(Order by AddTime) AS RowNumber,* FROM forumPost  where threadID='{0}') a  WHERE  RowNumber > 0";
    %>
    <%
        System.Data.DataTable dt = bll.GetDataBySqlComm(string.Format(_strSql, _threadID));
        System.Data.DataTable _dt = bll.GetDataBySqlComm(string.Format("select subject from forumThread where id='{0}'", _threadID));
    %>
    <div class="forumSubject">
        主题:<span style="font-weight: bold"><%=_dt.Rows[0].ItemArray[0].ToString() %></span></div>
    <%
        if (dt != null)
        {
            int num = 0;
            foreach (System.Data.DataRow row in dt.Rows)
            {
                
    %>
        <table class="forumPostList" cellpadding=0 cellspacing=0 border=1>
            <tr>
                <td class="forumAvter">
                    <img  src="" style="width:100px; height:120px;" /><br />
                 <div id="INFO<%=System.Int32.Parse(row.ItemArray[0].ToString())-1%>"> <% =GetUserInfo(row.ItemArray[dt.Columns["AddUser"].Ordinal])%></div>
                </td>
                <td  style="vertical-align:top;height:25px;">
                  <div class="forumDate">
                  <%if (num == 0)
                    { %>
                   <span  id="DT<%=System.Int32.Parse(row.ItemArray[0].ToString())-1%>"> 发贴时间：<%=row.ItemArray[dt.Columns["AddTime"].Ordinal]%></span><div style="float:right;margin-right:10px;"><a href="javascript:ReplyPost(<%=System.Int32.Parse(row.ItemArray[0].ToString())-1%>)">引用</a></div><div style="float:right;margin-right:10px;"><a href="javascript:Reply()">回复</a></div><div style="float:right;margin-right:10px;">楼主</div></div> 
                  <%}
                    else
                    {%>
                  <span id="DT<%=System.Int32.Parse(row.ItemArray[0].ToString())-1%>">  回复时间：<%=row.ItemArray[dt.Columns["AddTime"].Ordinal]%></span><div style="float:right;margin-right:10px;"><a href="javascript:ReplyPost(<%=System.Int32.Parse(row.ItemArray[0].ToString())-1%>)">引用</a></div><div style="float:right;margin-right:10px;"><a href="javascript:Reply()">回复</a></div><div style="float:right; margin-right:10px;">#<%=System.Int32.Parse(row.ItemArray[0].ToString())-1%>楼</div></div> 
                    <%}%>
                  
                  <div class="forumContent" id="N<%=System.Int32.Parse(row.ItemArray[0].ToString())-1%>"><%=row.ItemArray[dt.Columns["PostContent"].Ordinal] %></div>
                </td>
            </tr>
        </table>
        <%
            num++;
        }
        }         
    %>
</asp:Content>
